Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix markdownlint execution in the CI pipeline #154

Merged
merged 5 commits into from
Oct 4, 2023
Merged

Conversation

waldyrious
Copy link
Collaborator

@waldyrious waldyrious commented Jul 21, 2023

Follow up from the conversation from #153.

The advanced glob expression we were using needs to be quoted, as explained in https://github.com/igorshubovych/markdownlint-cli#globbing:

markdownlint-cli supports advanced globbing patterns like **/*.md. With shells like Bash, it may be necessary to quote globs so they are not interpreted by the shell.

@waldyrious waldyrious marked this pull request as draft July 21, 2023 11:21
@waldyrious waldyrious marked this pull request as ready for review July 21, 2023 11:21
@waldyrious waldyrious force-pushed the fix-markdownlint-glob branch from cf26b3b to e32169b Compare July 21, 2023 11:32
@waldyrious
Copy link
Collaborator Author

Grr, the checks are not running for some reason :(

@waldyrious waldyrious force-pushed the fix-markdownlint-glob branch from e32169b to a73409b Compare July 21, 2023 11:37
@Xymph
Copy link
Collaborator

Xymph commented Jul 21, 2023

Grr, the checks are not running for some reason :(

One still isn't. Formatting the changelog PR reference with [] instead of an actual link at the end of the file seems to cause the error, and also deviates from what we've done until now. Try with the old mechanism?

@waldyrious
Copy link
Collaborator Author

That's deliberate, actually. It turns out that markdownlint is not able to detect the missing link target in reference links when we use the shortcut syntax [foo], but it can when we use the collapsed syntax [foo][]. I have opened DavidAnson/markdownlint#915 to ask for that feature, but until that's implemented and released, we need to resort to using the collapsed syntax to make the links be processed.

I'm no longer blocked but I ran out of time. 😅 I'll get back to experimenting with this PR ASAP.

@Xymph
Copy link
Collaborator

Xymph commented Jul 22, 2023

Well, in that case, I think I'll go ahead to prepare v1.1 with the missing link, and this PR can be wrapped up later. It doesn't need to hold up the release.

But no longer having to expand the long link list in the future would be nice indeed. I'm just wondering whether the collapsed link will find the PRs in the original repo, even when viewing the changelog in our forks?

@waldyrious
Copy link
Collaborator Author

Well, in that case, I think I'll go ahead to prepare v1.1 with the missing link, and this PR can be wrapped up later. It doesn't need to hold up the release.

Why keep the missing link in the release? I would fix the link which we have already detected as missing, since that is orthogonal to the automated detection of future missing links.

But no longer having to expand the long link list in the future would be nice indeed. I'm just wondering whether the collapsed link will find the PRs in the original repo, even when viewing the changelog in our forks?

Oh, sorry, I'm afraid I gave you the wrong impression. The list at the end of the file still needs to be there regardless of whether we use the [foo] or the [foo][] syntax for the links; the only difference would be to have markdownlint warn us when one of the entries there is missing, so that the same issue won't go unnoticed again.

@Xymph
Copy link
Collaborator

Xymph commented Jul 22, 2023

My bad wording, I meant: "prepare v1.1 while adding the missing link"

Oh, okay, I had the impression the new syntax would magically link the PR somehow. Carry on then. 😄

@waldyrious waldyrious force-pushed the fix-markdownlint-glob branch 3 times, most recently from c20230d to fe47fbf Compare September 10, 2023 16:38
@waldyrious
Copy link
Collaborator Author

waldyrious commented Sep 10, 2023

Ok, I think I've got this pretty much ready. Now we just need to wait for a new release of markdownlint-cli or markdownlink-cli2 that includes support for markdownlint 0.31.0 (the version that introduced support for the shortcut syntax checking I asked for as mentioned above — thanks @DavidAnson!).

Afterwards (and upon confirming that the markdownlint-problem-matcher action does indeed detect a missing URL error in CHANGELOG.md and show it inline) I'll clean up the commits in this PR (there are now other changes beyond quoting the glob expression) so it'll be ready to merge.

@DavidAnson
Copy link

Soon!

As mentioned in <https://github.com/igorshubovych/markdownlint-cli#globbing>:

> `markdownlint-cli` supports advanced globbing patterns like `**/*.md`.
> With shells like Bash, it may be necessary to quote globs
> so they are not interpreted by the shell.
By default, markdownlint detects missing link targets
in reference links written in the "collapsed syntax" `[foo][]`,
but not if they use the "shortcut syntax" [foo].

Since markdownlint 0.31.0, the rule MD052/reference-links-images
now supports a `shortcut_syntax` boolean parameter
that allows opting-in to checking shortcut syntax links as well.

This requires markdownlint-cli v0.37.0 or above,
but since our GitHub Actions setup fetches the latest available version,
we already have access to it in the CI pipeline,
so we only need to add the rule and parameter
in the markdownlint configuration file.
@waldyrious waldyrious force-pushed the fix-markdownlint-glob branch from b64b94a to 4cd37b0 Compare October 3, 2023 23:41
@waldyrious waldyrious changed the title Quote advanced glob expression in markdownlint invocation Fix markdownlint execution in the CI pipeline Oct 3, 2023
@waldyrious
Copy link
Collaborator Author

waldyrious commented Oct 3, 2023

Alright! Now that markdownlint-cli has gotten a new release that includes markdownlint 0.31.0 (and therefore supports the new shortcut_syntax parameter for the MD052 rule), the npm install command in the GitHub Actions workflow will automatically get the new version; so we are now able to add that parameter to our .markdownlint.yml file (which I did in df41164) and get warnings for undefined reference link targets.

I have confirmed that an undefined URL reference does produce a markdownlint violation in the CI with the new config option. After that test I reverted the violation, naturally. I also cleaned up the commits and renamed the PR to be more accurate.

@Xymph this should now be ready to merge — please take a look at your convenience!

@Xymph Xymph merged commit e6d3fda into master Oct 4, 2023
2 checks passed
@Xymph
Copy link
Collaborator

Xymph commented Oct 4, 2023

Lookin' good. 👍

@waldyrious waldyrious deleted the fix-markdownlint-glob branch October 5, 2023 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants